# -* - coding: UTF-8 -* -
#import sys
#reload(sys)
#sys.setdefaultencoding('utf8')

import string
import logging
import json

#存放通知订阅者
class NotifyClient():  
	def __init__(self,command,url,data):  
		self.command=command
		self.url=url
		self.method=''
		self.data=data
	#**
	# Json字符串生成任务
	# @access public
	# @return mixed
	#/
	def fromJson(self,s):
		data=json.loads(s)
		if data and data.get('command',False):
			self.command=data.get('command','')
			self.url=data.get('url','')
			self.method=data.get('method','')
			self.data=data.get('data',None)
	
	#*
	# 任务转换成Json字符串
	# @access public
	# @return string
	#/
	def toJson(self):
		ret={}
		ret['command']=self.command
		ret['url']=self.url
		ret['method']=self.method
		ret['data']=self.data
		return json.dumps(ret)